package com.nullpointer.playerinfo.bungee;

import com.nullpointer.playerinfo.common.Base;
import com.nullpointer.playerinfo.common.Methods;
import com.nullpointer.playerinfo.common.objects.Correspond;
import com.nullpointer.playerinfo.common.objects.Player;

import net.md_5.bungee.api.ProxyServer;

public class Corresponder extends Correspond {

    public Corresponder(String host, int port, int serverCode) {
        super(host, port, serverCode);
    }
    
    @Override
    public void handleMessage(String message) {
        String[] args = Methods.getArgs(message);
        Player target = Base.playerMap.get(ProxyServer.getInstance().getPlayer(args[2]).getUniqueId());
        if (args.length == 3) {
            if (args[1].equals("removedata")) {
                target.removeData();
            }
        } else if (args.length == 4) {
            switch (args[1]) {
                case "addexp":
                    target.addExp(Integer.valueOf(args[3]));
                    break;
                case "removeexp":
                    target.removeCash(Integer.valueOf(args[3]));
                    break;
                case "addcash":
                    target.addCash(Integer.valueOf(args[3]));
                    break;
                case "removecash":
                    target.removeCash(Integer.valueOf(args[3]));
                    break;
                default:
                    break;
            }
        }
    }
    
}